package calendar;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;

/**
 *
 * @author angelika
 */
public class Events extends JPanel {
    JTextArea eventsArea;
    JScrollPane eventsPane;
    JButton saveButton;
    Calendar parent;
    
    public Events(Calendar cal) {
        parent = cal;
        eventsArea = new JTextArea(10, 10);
        eventsPane = new JScrollPane(eventsArea);
        saveButton = new JButton("Сохранить");
        saveButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent ae) {
                parent.saveEvent();
            }
        });
        
        eventsArea.setLineWrap(true);
        
        setOpaque(false);
        setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
        add(eventsPane);
        add(saveButton);
    }
    
    public void showEvent(String event) {
        eventsArea.setText(event);
    }
    
    public String getEvent() {
        return eventsArea.getText();
    }
}
